﻿using System;

namespace EzDesk.Utility.Extensions
{
    public static class EpochDateTimeExtension
    {
        public static int ToEpoch(this DateTime dateTime)
        {
            return (int)((dateTime.ToUniversalTime().Ticks - 621355968000000000) / 10000000);
        }

        public static DateTime FromEpoch(long epoch)
        {
            var timeDiff = DateTime.Now - DateTime.Now.ToUniversalTime();
            return new DateTime(epoch * 10000000 + 621355968000000000) + timeDiff;
        }
    }
}
